﻿
@model Menu
@{
    var sessionMenu = Session["menuSelect"] != null ? Session["menuSelect"].ToString() : "m1";
    List<Menu> lstMenu = ViewBag.lstMenu != null ? (List<Menu>)ViewBag.lstMenu : new List<Menu>();   
}


<ul class="menu">
@{
    int _count = 1;
    List<Menu> lstMenuParent = lstMenu.Where(d => d.ParentID == 0).OrderBy(d => d.MenuOrder).ToList();
    foreach (var item in lstMenuParent)
    {
        var className = "m" + _count;
        _count++;
        
       <li class="@className">
            <a onclick="setSelectMenu('@className','@item.MenuUrl')">@item.MenuName</a>
       @{
            List<Menu> lstMenuChil = lstMenu.Where(d => d.ParentID == item.MenuID).OrderBy(d => d.MenuOrder).ToList();
            if (lstMenuChil != null && lstMenuChil.Count > 0)
            {
                     <ul class="subnav">
                        @{
                int _itemcount = 1;
                foreach (var itemChil in lstMenuChil)
                {
                    var classItemChil = className + "-" + _itemcount;
                    _itemcount++;
                        <li class="@classItemChil"><a onclick="setSelectMenu('@className','@itemChil.MenuUrl')">@itemChil.MenuName</a></li>
                }
                            }
                    </ul>
            }

        }

        </li>
    }
    
    }

    </ul>


    <script type="text/javascript">

        $(document).ready(function () {           
            var sessionMenu = '@sessionMenu';              
            var crMenu = $("#menu ul.menu").find("li." + sessionMenu);
            crMenu.addClass("current");
            //setCurr(crMenu);

        });

</script>


       @*menu*@
 <script src="../../Scripts/menu.js" type="text/javascript"></script> 